local sharedLibs = game.ReplicatedStorage.SharedLibs;
local oo = require(sharedLibs.BaseLib)

AABB = require(script.Parent.AABB);
MathUtil = require(script.Parent.MathUtil);

local RandF = MathUtil.RandF;

--- 从一个Part(只能是Block形态的)构造一个 Area
--- 这个Part可以有旋转.
local BlockArea = oo.class("BlockArea");

function BlockArea:constructor(part)
	assert(part.Shape == Enum.PartType.Block);
	self._part = part;
	self._reverseCF = part.CFrame:inverse();
	--- 注意：这个AABB中心在原点
	self._aabb = AABB.FromSize(self._part.Size);
end

function BlockArea:GetRndPt()
	return MathUtil.RndPtInPart(self._part);
end

function BlockArea:CheckPt(pt)
	local localPt = self._reverseCF * pt;	
	return self._aabb:CheckPt(localPt);	
end

return BlockArea;